home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / grn / hpoint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-04  |  895 b   |  51 lines

  1. /*    hpoint.c    1.1    84/10/08    */
  2. /*
  3.  * This file contains routines for manipulating the point data
  4.  * structures for the gremlin picture editor.
  5.  */
  6.  
  7. #include "gprint.h"
  8.  
  9. /* imports from C */
  10.  
  11. extern char *malloc();
  12.  
  13.  
  14. /*
  15.  * Return pointer to empty point list.
  16.  */
  17. POINT *
  18. PTInit()
  19. {
  20.     return((POINT *) NULL);
  21. }
  22.  
  23.  
  24. /*
  25.  * This routine creates a new point with coordinates x and y and 
  26.  * links it into the pointlist.
  27.  */
  28. POINT *
  29. PTMakePoint(x, y, pplist)
  30. float x, y;
  31. POINT **pplist;
  32. {
  33.     register POINT *point;
  34.  
  35.     if (Nullpoint(point = *pplist)) {    /* empty list */
  36.     *pplist = (POINT *) malloc(sizeof(POINT));
  37.     point = *pplist;
  38.     }
  39.     else {
  40.     while (!Nullpoint(point->nextpt))
  41.         point = point->nextpt;
  42.     point->nextpt = (POINT *) malloc(sizeof(POINT));
  43.     point = point->nextpt;
  44.     }
  45.  
  46.     point->x = x;
  47.     point->y = y;
  48.     point->nextpt = PTInit();
  49.     return(point);
  50. }  /* end PTMakePoint */
  51.